package com.ruantong.dingtalk.ding.util;

import com.ruantong.dingtalk.ding.exception.DingRequestException;
import com.taobao.api.TaobaoResponse;

/**
 * @description:检查调用钉钉接口是否成功，抛出的异常不建议自行catch
 * @author: jh.chen
 * @time: 2020/11/15 15:50
 */
public class PreCheckResponse {
    public static <T extends TaobaoResponse> boolean isSuccess(T response) throws DingRequestException {
        boolean isSuccess = response.isSuccess();
        if (!isSuccess) {
            throw new DingRequestException(response.getRequestUrl());
        }
        return isSuccess;
    }
}
